/*
 * Copyright (c) 2020 solidwang. All Rights Reserved
 */
package com.solidwang.mybatis.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum Code {

    SUCCESS(0, "成功"),
    PARAM_ERROR(100, "参数错误"),
    SERVER_ERROR(500, "服务端错误");

    private Integer code;

    private String message;

    public static Code valueOf(Integer code) {
        if (code != null) {
            for (Code codeEnum : Code.values()) {
                if (codeEnum.getCode().equals(code)) {
                    return codeEnum;
                }
            }
        }
        return null;
    }

}
